Skip to content

fix(139): surface SMS verification during refresh fallback - #190

Merged
PIKACHUIM merged 1 commit into
mainfrom
fix/139-sms-refresh-fallback
Nov 9, 2026
Merged

PIKACHUIM merged 1 commit into
mainfrom
fix/139-sms-refresh-fallback

Conversation

@PIKACHUIM

Copy link
Copy Markdown
Member

后续 PR 正文

fix(139): surface SMS verification during refresh fallback

基线:origin/main = 38cfdc4(#164 的 squash merge)
分支:fix/139-sms-refresh-fallback
提交:67e0601 fix(139): surface SMS verification during refresh fallback

Summary / 摘要

#164 的 squash merge 漏掉了最后一个提交 ff8c863。本 PR 补上这一行:刷新失败触发密码重登录、且 139 邮箱要求短信验证时,不再吞掉 Yun139SmsRequiredError,而是先保存更新后的 MailCookies,再把“请填写 sms_code”的错误抛给用户。

Motivation / 背景

  • 原 PR 合并到 main 时只到 9bfd4fe,缺少 ff8c863。
  • 当前 main 的 tryReLogin() 捕获短信风控异常后只写 debug 日志并 return false,外层最终抛出 PC/旧接口刷新错误,用户看不到需要填写验证码的提示。
  • 行为与 Go 的 loginAfterAuthorizationFailure 不一致:Go 会把登录错误(含短信提示)返回给用户。

Changes / 改动内容

src/backend/drivers/139/util.ts:

  • tryReLogin() 捕获 Yun139SmsRequiredError 时:
    1. 更新 addition.mail_cookies;
    2. 通过 onLoginStateChange 持久化;
    3. throw e,让调用方收到短信验证提示。
  • 其他登录失败仍保持原有降级:debug 日志 + return false。
if (e instanceof Yun139SmsRequiredError) {
  this.addition.mail_cookies = e.mailCookies
  await this.onLoginStateChange?.({
    authorization: "",
    account: this.account,
    userDomainId: (this.addition.user_domain_id || "").trim(),
    mailCookies: e.mailCookies,
    smsCode: (this.addition.sms_code || "").trim(),
  })
  throw e
}

Testing / 验证

npx tsx --test src/backend/drivers/139/*.test.ts
# 25 passed / 0 failed

npx tsc -p tsconfig.json --noEmit
# 无报错

Compatibility / 兼容性

  • 单行行为修复,无接口、配置、数据库变更。
  • 不影响没有用户名/密码的配置:仍走原有刷新或跳过逻辑。
  • 不改变手动 user_domain_id 与 Authorization 的优先级。
  • 不改变已有刷新成功路径。
  • 不影响没有触发短信风控的密码重登录。

Checklist

When a refresh failure triggers password login and 139 Mail asks for an
SMS code, propagate Yun139SmsRequiredError instead of swallowing it and
reporting only the original refresh error. The refreshed mail_cookies are
still persisted first, so the next save with sms_code can continue.

Tests: 139 driver 25/25, tsc clean.
@PIKACHUIM PIKACHUIM linked an issue Nov 9, 2026 that may be closed by this pull request
4 tasks done
@PIKACHUIM
PIKACHUIM merged commit 6e11cfb into main Nov 9, 2026
3 checks passed
WMZZwmzz added a commit to WMZZwmzz/OpenList-Worker that referenced this pull request Nov 14, 2026
合并 OpenListTeam/OpenList-Worker 上游 main(82bd05d..e6eb21f,21 个提交),
保留本仓库全部安全加固与本地特性:

上游引入:
- feat(media): 媒体库 / Emby / Subsonic 完整对齐(OpenListTeam#148),路由已挂载
- feat(mega): Hashcash 工作量证明 + 会话持久化(OpenListTeam#166/OpenListTeam#152 相关)——移植
  generateHashcashToken 至本地 mega 实现,保留本地流式下载与纯 JS 密码学
- feat(config): wrangler keep_vars(OpenListTeam#176);alias iconv-lite 空桩(OpenListTeam#160)
- fix(webdav): 下载重定向签名(OpenListTeam#187/OpenListTeam#175),统一走 appendDownloadSignToRawUrl
- fix(auth): guest 默认禁用(OpenListTeam#162/OpenListTeam#133);2FA QR SVG(OpenListTeam#153,本地保留自研 PNG 实现)
- fix(139): SMS 验证码登录状态回调(OpenListTeam#190/OpenListTeam#164)——本地 singleflight 与
  still-valid 降级保留,叠加 onLoginStateChange 持久化
- refactor(cache)!: 移除持久缓存与 singleflight(OpenListTeam#185),本地 cache 审计修复
  (F-104/F-106)随之失效但安全语义由无缓存架构天然保证
- fix(115): 移除损坏的 legacy 115 驱动(OpenListTeam#152),旧别名统一路由 Pan115Driver
- refactor(driver): put() 内容契约统一 Uint8Array(OpenListTeam#173/OpenListTeam#169)

本地保留(关键项):
- 驱动注册表架构(F-271/F-090 精确匹配)+ 全部 25 处刷新令牌持久化回调
- pkg/totp 自研 QR、pkg/upload-limit 流式上限判定(F-057)、pkg/sign
  专用下载签名密钥 + canonicalVirtualPath + scope 支持
- op/storage F-039 setup 锁内重读、F-005 挂载点复查;sql 格式 90 参数
  预算分批(F-083,上游 OpenListTeam#184 同源修复);readBodyWithinLimit 流式读取
- 139 getDisk 分页/encodeURI 方向/CSPRNG、115open parentPath、
  mega TOTP/流式下载、weiyun F-166 无哈希上传、ftp F-262 时序
- DB_CIPHER 默认 aes-256-gcm、EdgeOne frozen-lockfile、OpenList Moe 主题
- getDriver deferTokenPersistence 修复为 return await(延迟令牌持久化
  需覆盖驱动 init 全程;此隐患 base/上游均存在)

验证:tsc 0 错误;build 通过(Moe 主题注入正常);test:all 8 套
1366 用例全部通过。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] 139云盘configure user_domain_id to use the PC refreshToken API

1 participant